<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>显示浏览某页面的时间——Document 对象</title>
    <style>
        body {
            background-color: #fef4d2;
        }

        h2,
        p {
            text-align: center;
        }
    </style>
</head>

<body onload=Timetrack()>
    <h2>浏览本页面所用时间</h2>
    <hr>
    <form name="time">
        <p>浏览本页面总共用去
            <input type="text" name="timer" size="6" value="0:00">秒
        </p>
    </form>
    <script type="text/javascript">
        var entered = new Date();
        function Timetrack() {
            var now = new Date();
            var seconds = Math.floor((now.getTime() - entered.getTime()) / 1000);
            var minutes = parseInt(seconds / 60);
            var second = seconds % 60;
            var minute = minutes % 60;
            document.time.timer.value = minutes + ":" + seconds;
            setTimeout("Timetrack()", 1000);
        }
        Timetrack();
    </script>
</body>
<html>
